#define N 1000
double integrate(double a,double b) {
    double dx=(b-a)/N,tot=0;
    int i;
    for(i=0; i<N; i++) {
        double top=sin(a+dx*i);
        double bottom=sin(a+dx*(i+1));
        double h=dx;
        tot+=(top+bottom)*h/2;
    }
    return tot;
}
double integrate2(double a,double b) {
    double dx=(b-a)/N,tot=0;
    int i;
    for(i=0; i<N; i++) {
        double top=cos(a+dx*i);
        double bottom=cos(a+dx*(i+1));
        double h=dx;
        tot+=(top+bottom)*h/2;
    }
    return tot;
}
double g(double x){
    return x*x+cos(sin(x));
}
int main() {
    printf("%f\n",integrate(0,1));
    printf("%f\n",cos(0)-cos(1));

}
